This is an example of plotting data from TXPWD. The Gould Eco Regions data can be found here.
Load sf
.
library(tidyverse) library(sf)
Read in the shapefile.
ger <- st_read("GouldEcoRegions.shp") %>% st_simplify(dTolerance = 1e3)
Print summary of the columns.
summary(ger)
Look the Coordinate Reference System. Its the Texas State Mapping System.
st_crs(ger)
We can plot using the sf
plot function.
if (compareVersion(as.character(packageVersion("ggplot2")), "2.2.1") < 1) devtools::install_github("hadley/ggplot2") library(ggplot2)
ggplot() + geom_sf(data = ger, aes(fill = Shape_Area)) -> er.plot er.plot
er.plot + geom_sf(data = st_centroid(ger), color = "red")
Read in park boundaries
parks <- st_read("TPWDStateParksBoundary.shp") %>% st_simplify(dTolerance = 1e3)
With buffering and alpha, we can create a halo around parks to make small polygons more visible.
er.plot + geom_sf(data = st_buffer(parks, 2e4), color = NA, fill = "darkred", alpha = 0.25) + geom_sf(data = parks, color = "red", fill = NA)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.